Dart.Sockets Namespace > UdpBase Class > Receive Method : Receive(Byte[]) Method |
'Usage Dim instance As UdpBase Dim buffer() As Byte Dim value As Datagram value = instance.Receive(buffer)
public: Datagram^ Receive( array<byte>^ buffer )
Exception | Description |
---|---|
System.ArgumentNullException | buffer is null. |
Use the Receive method to receive a datagram into buffer. This method also returns a Datagram object encapsulating the datagram received. Segment.Buffer contains the actual datagram data (equivalent to buffer). Datagram.Origin contains the endpoint of the remote host from which the datagram was sent.
A UDP datagram provides little functionality over an IP datagram, adding a port number field (allows demultiplexing on the receiving host) and a checksum field (provides basic error handling). Unlike TCP, UDP datagrams are sent as a unit. If Send is called 3 times to send 3 datagrams to a host, the receiving host will have to call Receive 3 times. Also, the size of each datagram sent will equal the size of each datagram received by the receiving host. In addition, since UDP is a connectionless protocol, datagrams sent to the host are not guaranteed to be delivered. Therefore, any required error checking (outside of UDP's checksum implementation) will have to be done by the application-layer protocol.